//
//  XLVideoPushFinishView.m
//  XiangLove
//
//  Created by 李传坤 on 2018/4/9.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLVideoPushFinishView.h"
#import "UIImage+Gradient.h"
@interface XLVideoPushFinishView ()
@property (strong, nonatomic) UIImageView *LevelImageView;
@property (strong, nonatomic) UILabel *CongratulationLabel;//恭喜label

@property (strong, nonatomic) UIView *alertView;
@property (strong, nonatomic) UIButton *dismissButton;



@end

@implementation XLVideoPushFinishView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        // 设置背影为透明色
        self.backgroundColor = [UIColor whiteColor];
        [self addViews];
    }
    return self;
}
- (void)addViews{
    
    
    _alertView = [[UIView alloc]init];
    _alertView.backgroundColor = [UIColor whiteColor];
    _alertView.frame = self.frame;
    [self addSubview:_alertView];
    
    _LevelImageView = [[UIImageView alloc]init];
    [_alertView addSubview:_LevelImageView];
    [_LevelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_alertView.mas_centerY).offset(-120);
        make.centerX.equalTo(_alertView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(250, 173));
    }];
    _LevelImageView.image = [UIImage imageNamed:@"pic_tijiaochenggong.png"];
    
    
    _LevelLabel = [[UILabel alloc]init];
    [_alertView addSubview:_LevelLabel];
    [_LevelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_LevelImageView.mas_bottom).offset(10);
        make.left.equalTo(_alertView.mas_left);
        make.right.equalTo(_alertView.mas_right);
        make.size.mas_equalTo(CGSizeMake(100, 50));
    }];
    _LevelLabel.text = @"提交成功";
    _LevelLabel.textColor = kBlackColor;
    _LevelLabel.font = [UIFont systemFontOfSize:22];
    _LevelLabel.textAlignment = NSTextAlignmentCenter;
    
    
    _CongratulationLabel = [[UILabel alloc]init];
    _CongratulationLabel.text = @"将在1个小时内给你反馈审核结果 会通过小秘书账号通知你请关注APP中的消息通知";
    _CongratulationLabel.textColor = [UIColor lightGrayColor];
    _CongratulationLabel.textAlignment = NSTextAlignmentCenter;
    _CongratulationLabel.numberOfLines = 2;
    _CongratulationLabel.font = [UIFont systemFontOfSize:14];
    [_alertView addSubview:_CongratulationLabel];
    [_CongratulationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_LevelLabel.mas_bottom).offset(40);
        make.centerX.equalTo(_alertView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(300, 50));
    }];

    
    _dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _dismissButton.frame = CGRectMake(50, SCREEN_HEIGHT - 120, SCREEN_WIDTH - 100, 50);
    [_dismissButton setTitle:@"我知道了" forState:UIControlStateNormal];
    _dismissButton.layer.cornerRadius = 25; _dismissButton.layer.masksToBounds = YES;
    [_dismissButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
    [_dismissButton setBackgroundColor:RGB_HEX(0xffbb01)];
    [self addSubview:_dismissButton];
}

-(void)show{
    [[[[UIApplication sharedApplication]delegate]window]addSubview:self];
}
-(void)dismiss{
    _block();
    [UIView animateWithDuration:0.3
                          delay:0.0
                        options: UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         self.alpha = 0;
                     }
                     completion:^(BOOL finished){
                         [self removeFromSuperview];
                     }];
}


@end
